﻿<Window x:Class="ForumsBrowser.PopupAlert"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fb="clr-namespace:ForumsBrowser"
    Title="PopupAlert" Height="90" Width="300" Padding="2,2,2,2" 
    WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False"
    AllowsTransparency="True" Background="Transparent"
    Loaded="PopupAlert_Loaded" MouseLeftButtonDown="Window_MouseLeftButtonDown">
    <Window.Resources>
        <Storyboard x:Key="dropItem">
            <DoubleAnimation Storyboard.TargetProperty="Top" By="90" Duration="0:0:0.2"/>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger RoutedEvent="Window.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.Target="{Binding ElementName=border}" 
                        Storyboard.TargetProperty="Height" From="0" To="90" BeginTime="0:0:0" Duration="0:0:0.5"/>
                    <DoubleAnimation Storyboard.Target="{Binding ElementName=border}" 
                        Storyboard.TargetProperty="Width" From="0" To="300" BeginTime="0:0:0" Duration="0:0:0.5"/>
                    <DoubleAnimation Storyboard.Target="{Binding ElementName=border}" 
                        Storyboard.TargetProperty="Height" From="90" To="0" BeginTime="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type fb:PopupAlert} }, Path=PopupDuration }" Duration="0:0:0.5" Completed="DoubleAnimation_Completed"/>
                    <DoubleAnimation Storyboard.Target="{Binding ElementName=border}" 
                        Storyboard.TargetProperty="Width" From="300" To="0" BeginTime="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type fb:PopupAlert} }, Path=PopupDuration }" Duration="0:0:0.5" Completed="DoubleAnimation_Completed"/>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Window.Triggers>
    <Border x:Name="border" Grid.RowSpan="3" Grid.ColumnSpan="2" CornerRadius="5,5,5,5" Padding="2,2,2,2" BorderThickness="1.5" HorizontalAlignment="Center" VerticalAlignment="Center" >
        <Border.BorderBrush>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="White" Offset="1"/>
                    <GradientStop Color="Gray"/>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Border.BorderBrush>
        <Border.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,.7">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="Black" Offset="1" />
                    <GradientStop Color="{Binding Converter={StaticResource ThreadColorConverter} }" Offset="-.6" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Border.Background>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <fb:ImageToken Grid.RowSpan="2" Grid.Row="1" ImageUrl="{Binding LastMessageBy.Image}"/>
            <TextBlock Grid.Row="0" Margin="1"  Grid.Column="0" FontSize="14" Grid.ColumnSpan="2" Text="{Binding Title}" TextTrimming="CharacterEllipsis" />
            <TextBlock Grid.Row="1" Margin="1"  Grid.Column="1" FontSize="10" FontStyle="Italic" Text="{Binding LastMessageBy.DisplayName}"/>
            <TextBlock Grid.Row="2" Margin="1" Text="{Binding LastMessageText}" Grid.Column="1" TextWrapping="Wrap"/>
        </Grid>
    </Border>
</Window>
